package com.bjc.scheduler.elasticjob.quickstart.demo;

import java.time.LocalDateTime;
import java.util.concurrent.Executors;
import java.util.concurrent.ScheduledExecutorService;
import java.util.concurrent.TimeUnit;

/**
 * @program: elastic-job-quickstart
 * @description: ScheduledExecutorService实现定时任务
 * @author: bjc
 * @create: 2021-08-15 19:19
 */
public class SimpleDemo3 {

    public static void main(String[] args) {
        ScheduledExecutorService service = Executors.newScheduledThreadPool(10);
        service.scheduleAtFixedRate(()->{
            System.out.printf("time：%s to do something", LocalDateTime.now());
            System.out.println();
        },1,3, TimeUnit.SECONDS);
    }
}
